package com.job.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.job.controller.req.ChatRecordsVO;
import com.job.dao.MessageDao;
import com.job.mapper.MessageMapper;
import com.job.pojo.Message;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

@Repository
public class MessageDaoImpl implements MessageDao {

    @Resource
    private MessageMapper messageMapper;

    @Override
    public Page<Message> queryChatRecordsList(String conversationId, ChatRecordsVO chatRecordsVO) {
        Page<Message> messagePage = new Page<>();
        messagePage.setCurrent(chatRecordsVO.getCurrent());
        messagePage.setSize(chatRecordsVO.getSize());
        LambdaQueryWrapper<Message> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Message::getConversationId,conversationId);
        return messageMapper.selectPage(messagePage,wrapper);
    }
}
